/*
Copyright (c) 2025 HeZongLun
NahidaProject is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan
PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/

#include "TerminalColor.h"


HANDLE handleOfConsole = GetStdHandle(STD_OUTPUT_HANDLE);

std::ostream& NahidaProject::TerminalColor::Reset(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x0004 | 0x0002 | 0x0001); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::Red(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x0004); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::Orange(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0004 | 0x0006); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::Yellow(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x0004 | 0x0002); 
	return os;
}

std::ostream& NahidaProject::TerminalColor::Green(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x0002); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::Cyan(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x0002 | 0x0001); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::Blue(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x0001); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::Purple(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x000D); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::BackgroundRed(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x0040 | 0x0004 | 0x0002 | 0x0001);
	return os; 
}

std::ostream& NahidaProject::TerminalColor::BackgroundOrange(std::ostream& os) {
	SetConsoleTextAttribute(handleOfConsole, 0x0040 | 0x0020 | 0x0004 | 0x0002 | 0x0001); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::BackgroundYellow(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x00EE | 0x0004 | 0x0002 | 0x0001); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::BackgroundGreen(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x0022); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::BackgroundCyan(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x0020 | 0x0010 | 0x0004 | 0x0002 | 0x0001); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::BackgroundBlue(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x0010 | 0x0004 | 0x0002 | 0x0001); 
	return os; 
}

std::ostream& NahidaProject::TerminalColor::BackgroundPurple(std::ostream& os) { 
	SetConsoleTextAttribute(handleOfConsole, 0x0008 | 0x00DD | 0x0004 | 0x0002 | 0x0001); 
	return os; 
}
